package universe;

import java.util.ArrayList;

public class Utils {

	public static final int bonusValue = 20;
	
	private static final int BOARD_WIDTH = 14;
	private static final int BOARD_HEIGHT = 23;

	private static final int BLOCK_WIDTH = 4;
	private static final int BLOCK_HEIGHT = BLOCK_WIDTH;

	public static int timerMs = 500;
	
	public static final int nbLinesByLevel = 5;
	public static final int timerDecrementationByLevel = 10;
	public static final int minimalTimerMs = 100;

	public static int getTimerMs() {
		return timerMs;
	}

	public static void setTimerMs(int pValue) {
		timerMs = pValue;
	}
	
	public static void decrementTimerMs() {
		if(timerMs - timerDecrementationByLevel > minimalTimerMs)
			timerMs -= timerDecrementationByLevel;
	}

	public static int GAME_OVER_ANIMATION = 0;
	
	public static int bonus = 0;

	public static int getBlockWidth(){
		return BLOCK_WIDTH;
	}

	public static int getBlockHeight(){
		return BLOCK_HEIGHT;
	}

	public static int getBoardWidth(){
		return BOARD_WIDTH;
	}

	public static void resetBonus() {
		bonus = 0;
	}

	public static void addBonus() {
		bonus += bonusValue;
	}
	
	public static int getBonus() {
		return bonus;
	}

	public static int getBoardHeight(){
		return BOARD_HEIGHT;
	}




	// Piece S :
	public static ArrayList<int[][]> getBlockA(){

		ArrayList<int[][]> blockA = new ArrayList<int[][]>();

		int[][] pos0 = {{0,0,0,0},{2,2,0,0},{0,2,2,0},{0,0,0,0}};
		int[][] pos1 = {{0,0,0,0},{0,0,2,0},{0,2,2,0},{0,2,0,0}};
		
		blockA.add(pos0);
		blockA.add(pos1);
		blockA.add(pos0);
		blockA.add(pos1);
		return blockA;
	}

	// Piece Carrée :
	public static ArrayList<int[][]> getBlockB(){

		ArrayList<int[][]> blockB = new ArrayList<int[][]>();
		int[][] pos0 = {{0,0,0,0},{3,3,0,0},{3,3,0,0},{0,0,0,0}};

		blockB.add(pos0);
		blockB.add(pos0);
		blockB.add(pos0);
		blockB.add(pos0);
		return blockB;
	}


	// Piece | :
	public static ArrayList<int[][]> getBlockC(){

		ArrayList<int[][]> blockC = new ArrayList<int[][]>();

		int[][] pos0 = {{4,4,4,4},{0,0,0,0},{0,0,0,0},{0,0,0,0}};
		int[][] pos1 = {{4,0,0,0},{4,0,0,0},{4,0,0,0},{4,0,0,0}};

		blockC.add(pos0);
		blockC.add(pos1);
		blockC.add(pos0);
		blockC.add(pos1);
		return blockC;
	}	

	// Piece Z :
	public static ArrayList<int[][]> getBlockD(){

		ArrayList<int[][]> blockD = new ArrayList<int[][]>();
		int[][] pos0 = {{0,0,0,0},{0,5,5,0},{5,5,0,0},{0,0,0,0}};
		int[][] pos1 = {{0,0,0,0},{0,5,0,0},{0,5,5,0},{0,0,5,0}};

		blockD.add(pos0);
		blockD.add(pos1);
		blockD.add(pos0);
		blockD.add(pos1);
		return blockD;
	}	

	// Piece T :
	public static ArrayList<int[][]> getBlockE(){

		ArrayList<int[][]> blockE = new ArrayList<int[][]>();

		int[][] pos0 = {{0,0,0,0},{6,6,6,0},{0,6,0,0},{0,0,0,0}};
		int[][] pos1 = {{0,0,0,0},{0,6,0,0},{0,6,6,0},{0,6,0,0}};
		int[][] pos2 = {{0,0,0,0},{0,6,0,0},{6,6,6,0},{0,0,0,0}};
		int[][] pos3 = {{0,0,0,0},{0,0,6,0},{0,6,6,0},{0,0,6,0}};

		blockE.add(pos0);
		blockE.add(pos1);
		blockE.add(pos2);
		blockE.add(pos3);
		return blockE;
	}	

	// Piece J :
	public static ArrayList<int[][]> getBlockF(){

		ArrayList<int[][]> blockF = new ArrayList<int[][]>();
		int[][] pos0 = {{0,0,0,0},{0,0,7,0},{7,7,7,0},{0,0,0,0}};
		int[][] pos1 = {{0,0,0,0},{0,7,0,0},{0,7,0,0},{0,7,7,0}};
		int[][] pos2 = {{0,0,0,0},{7,7,7,0},{7,0,0,0},{0,0,0,0}};
		int[][] pos3 = {{0,0,0,0},{0,7,7,0},{0,0,7,0},{0,0,7,0}};

		blockF.add(pos0);
		blockF.add(pos1);
		blockF.add(pos2);
		blockF.add(pos3);
		return blockF;
	}	

	// Piece L :
	public static ArrayList<int[][]> getBlockG(){

		ArrayList<int[][]> blockG = new ArrayList<int[][]>();
		int[][] pos0 = {{0,0,0,0},{8,8,8,0},{0,0,8,0},{0,0,0,0}};
		int[][] pos1 = {{0,0,0,0},{0,0,8,0},{0,0,8,0},{0,8,8,0}};
		int[][] pos2 = {{0,0,0,0},{8,0,0,0},{8,8,8,0},{0,0,0,0}};
		int[][] pos3 = {{0,0,0,0},{0,8,8,0},{0,8,0,0},{0,8,0,0}};

		blockG.add(pos0);
		blockG.add(pos1);
		blockG.add(pos2);
		blockG.add(pos3);
		return blockG;
	}

}
